package com.nuc.crp3;

/**
 * Time    : 2023/3/23 22:03
 * Author  : 王摇摆
 * FileName: Main1.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

/**
 * 新增橡皮鸭类
 * 进行类的动态扩展
 */
public class Main3 {
    public static void main(String[] args) {
        MallarDuck mallarDuck = new MallarDuck("MallarDuck");
        mallarDuck.display();
        mallarDuck.quark();
        mallarDuck.swim();
        mallarDuck.fly(mallarDuck.getName()); // 重写父类的方法，传参使用
        mallarDuck.duckFly();//子类定义实例方法，使用super关键字访问父类特征
        System.out.println("--------------------------");

        RedaheadDuck redaheadDuck = new RedaheadDuck("RedaheadDuck");
        redaheadDuck.display();
        redaheadDuck.quark();
        redaheadDuck.swim();
        redaheadDuck.fly(redaheadDuck.getName());
        System.out.println("--------------------------");

        RubberDuck rubberDuck = new RubberDuck("RubberDuck");
        rubberDuck.display();
        rubberDuck.quark();
        rubberDuck.swim();




    }
}
